﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace EDMS
{
    public partial class Delegate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                
            }

        }
        //社区通知
        void CommunityTz()
        {

        }
        //选举通知显示
        void SelectTz()
        {
            string CurrentXjbh = txtxjbhc.Text;
            using (DataClassesDataContext lqdb = new DAL.DataClassesDataContext())
            {
                var result = from r in lqdb.Xjgg
                             where r.xjbh == CurrentXjbh
                             select r;
                foreach (var item in result)
                {
                    lblgg.Text = item.nr;
                }
            }
        }
        //确认委托
        protected void btnDelegate_Click(object sender, EventArgs e)
        {

        }

        protected void gvShow_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            string name = "";    //被委托人姓名
            string idcard = "";  //被委托人身份证号码
            int i = 0;
            int j = 0;
            string str = e.Parameters.ToString();
            i = str.IndexOf("&");
            name = str.Substring(0, i);
            j = str.Length - i;
            idcard = str.Substring(i + 1, j - 1);
            string wtnametext = wtName.Text;
            string wtidcardtext = wtIDcard.Text;
            string CurrentXjbh = txtxjbhc.Text;

            if (!wtnametext.Equals("") || !wtidcardtext.Equals(""))
            {
                string strSql = "select * from Xm where {0} xjbh='" + CurrentXjbh + "'";
                StringBuilder sb = new StringBuilder();
                List<SqlParameter> paralist = new List<SqlParameter>();

                if (!string.IsNullOrEmpty(wtnametext))
                {
                    sb.Append("xmxm like '%'+ @name +'%' and ");
                    paralist.Add(new SqlParameter("@name", name));
                }

                if (!string.IsNullOrEmpty(wtidcardtext))
                {
                    sb.Append("sfzh like '%'+ @idcard +'%' and ");
                    paralist.Add(new SqlParameter("@idcard", idcard));
                }
                string strsql = string.Format(strSql, sb.ToString());
                gvShow.DataSource = Frame.Global.GlobalSqlHelper.ExecuteSQLToDataTable(strsql, paralist.ToArray());
                gvShow.DataBind();
            }

        }

        protected void gvCommunitys_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            //string name = Context.Request["newTag"].ToString();
            string name = newTag.Text;
            if (name != "")
            {
                DataTable dt = new DataTable();
                string strsql = "select * from Xjdj where xjmc like '%" + name + "%'";
                dt = Frame.Global.GlobalSqlHelper.ExecuteSQLToDataTable(strsql);
                gvCommunitys.DataSource = dt;
                gvCommunitys.KeyFieldName = "xjbh";
                gvCommunitys.DataBind();
            }
        }

        protected void gvCommunitys_SelectionChanged(object sender, EventArgs e)
        {
            int i = gvCommunitys.Selection.Count;
        }
    }
}